﻿using IV.Core.Enums;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Media;

namespace IV.Components.Log
{
    public class LogLevelToBrush : MarkupExtension, IValueConverter
    {
        public Brush DebugBrush = Brushes.Gray;
        public Brush InfoBrush = Brushes.Black;
        public Brush WarnBrush = Brushes.Orange;
        public Brush ErrorBursh = Brushes.OrangeRed;
        public Brush FatalBrush = Brushes.DarkRed;

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ELogLevel eLogLevel = (ELogLevel)value;
            return eLogLevel switch
            {
                ELogLevel.DEBUG => DebugBrush,
                ELogLevel.INFO => InfoBrush,
                ELogLevel.WARN => WarnBrush,
                ELogLevel.ERROR => ErrorBursh,
                ELogLevel.FATAL => FatalBrush,
                _ => DebugBrush
            };
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }
}
